/**
 * Created by losor on 2017/3/17.
 */
public class _374_GuessNumberHigherOrLower {

    public int guess(int num){
        return 1;
    }

    public int guessNumber(int n) {
        int left = 0;
        int right = n;
        int mid = 0;
        while(left<=right){
            mid = left + (right - left)/2;
            if(guess(mid)>0){
                left = mid +1;
            }
            else if(guess(mid)<0){
                right = mid -1;
            }
            else{
                return mid;
            }
        }
        return mid;
    }

}
